using System;
using System.Collections.Generic;
using Rogan.Utility.Common;

namespace Rogan.Data
{
	[Serializable]
	public class GroupByExpression : IDbExpression, ICloneable<GroupByExpression>, ITableResetable
	{
		public DbExpressionType ExpressionType
		{
			get
			{
				return DbExpressionType.GroupBy;
			}
		}
		public IList<Field> Fields
		{
			get;
			set;
		}
		public WhereExpression Having
		{
			get;
			set;
		}
		public GroupByExpression() : this(null)
		{
		}
		public GroupByExpression(Field field)
		{
			Fields = new List<Field>();
			if (field != null)
			{
				Fields.Add(field);
			}
		}
		public GroupByExpression Clone()
		{
			return DataHelper.Clone(this) as GroupByExpression;
		}
		public void SetTable(string tName)
		{
			if (Fields != null)
			{
				foreach (Field current in Fields)
				{
					current.SetTableName(tName);
				}
			}
		}
	}
}
